package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;

/**
 * 账户表，记录所有资金账户信息
 * @TableName account
 */
@TableName(value ="account")
@Data
public class Account implements Serializable {
    /**
     * 主键ID，账户的唯一标识，用于在系统中唯一确定一个账户
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 账户名称，用于区分不同的账户，例如银行账户名、现金账户名等
     */
    private String name;

    /**
     * 账户类型，表明账户的性质，如银行账户、现金账户等
     */
    private String type;

    /**
     * 是否默认账户，1表示是默认账户，0表示不是默认账户，默认账户在某些操作中会被优先使用
     */
    private Integer isDefault;

    /**
     * 期初金额，账户在初始设立时的金额
     */
    private BigDecimal initialAmount;

    /**
     * 当前金额，账户当前的实际余额，会随着资金的变动而更新
     */
    private BigDecimal currentAmount;

    /**
     * 租户ID，用于多租户环境下区分不同的租户，每个租户可以有自己独立的账户体系
     */
    private Long tenantId;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Account other = (Account) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
            && (this.getIsDefault() == null ? other.getIsDefault() == null : this.getIsDefault().equals(other.getIsDefault()))
            && (this.getInitialAmount() == null ? other.getInitialAmount() == null : this.getInitialAmount().equals(other.getInitialAmount()))
            && (this.getCurrentAmount() == null ? other.getCurrentAmount() == null : this.getCurrentAmount().equals(other.getCurrentAmount()))
            && (this.getTenantId() == null ? other.getTenantId() == null : this.getTenantId().equals(other.getTenantId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getIsDefault() == null) ? 0 : getIsDefault().hashCode());
        result = prime * result + ((getInitialAmount() == null) ? 0 : getInitialAmount().hashCode());
        result = prime * result + ((getCurrentAmount() == null) ? 0 : getCurrentAmount().hashCode());
        result = prime * result + ((getTenantId() == null) ? 0 : getTenantId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", name=").append(name);
        sb.append(", type=").append(type);
        sb.append(", isDefault=").append(isDefault);
        sb.append(", initialAmount=").append(initialAmount);
        sb.append(", currentAmount=").append(currentAmount);
        sb.append(", tenantId=").append(tenantId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}